/**@version
 * 2.2
 * 將所有query sql method 有 exception 時將sql print to consle.
 * 增加checkUserForTable(String strValidTable,String strUidFld,String strPWFld)
 * 可指定要使用那一個table 進行 user validation.
 */

package com.pub.check;

//增加的import (AD認證用到的)
import java.util.*;

import javax.naming.directory.*;

import com.pub.database.*;
import com.pub.encryption.*;
import com.pub.tools.*;

/**
 * Instance 後需先透過 setUsername and setPasswords 兩個method將要進行驗證的資訊填入<br>
 *
 * EX.CheckUserLogin chkUserLogin=new CheckUserLogin();<br>
 *
 * chkUserLogin.setUsername("05227");<br>
 * chkUserLogin.setPasswords("1234");<br>
 *
 * chkUserLogin.isValidUser();<br>
 *
 * <p>Title: CheckUserLogin </p>
 *
 * <p>Description: 驗證系統使用者輸入的帳號是否正確</p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: ALPHA </p>
 *
 * @author GM Lin,Andy Chen
 * @version 1.0
 */
public class CheckUserLogin {

    private boolean gblnDebug=false;  //讀取web.xml 的 debug value
    private String gstrInputUserName; //輸入的帳號，可能為EMPNO or EMAIL or DLINK_EMPNO
    private String gstrInputPassword; //輸入的密碼
    private String gstrEmpno; //EMPNO，因為前端輸入的值不一定都是EMPNO
    private String gstrEmpName; //EMPNAME，使用者英文姓名
    private String gstrErrMsg; //錯誤訊息
    private String gstrSpecialPassword; //特殊密碼,空白代表沒有特殊密碼

    private String strCheckType; //檢核方式，"AD"驗證或 "TABLE"驗證***deprecated
    private int intAD_NUM; //AD驗證的主機數目，先以前面的做驗證***deprecated
    private String strAD_URL; //AD驗證的ldap URL***deprecated
    private String strAD_CON; //AD驗證的container設定***deprecated
    private PropertyBean gptyBean = null; //DB_Config檔***deprecated

    /**
     * 以下為2006/9/25新增的全域變數
     */
    private String gstrDBAlias=null;
    private String gstrADAliasList=null;
    private String gstrValidTable=null;
    private String gstrUidFld=null;
    private String gstrPWFld=null;
    private String gstrEncryption=null;
    private String gstrAuthoriztionType=null;



    /**
     * 因有舊的Authorization(use WEB_Config.properties)暫時仍讓此建構子Active
     * @param prbdBean ResourceBundle
     * //@deprecated change to use CheckUserLogin(String pstrADAliasList,String strValidTable, String strUidFld,String strPWFld)
     */
    public CheckUserLogin(ResourceBundle prbdBean){
        this.gptyBean=new PropertyBean(prbdBean);
    }

    /*private CheckUserLogin(PropertyBean pptyBean) {
        this.gptyBean = pptyBean;
    }*/

    /**
     * 有參數建構元，初始化 gstrInputUserName,password的值
     * @param gstrInputUserName User ID
     * @param gstrInputPassword Passwords
     
    private CheckUserLogin(PropertyBean pptyBean, String gstrInputUserName,
                          String gstrInputPassword) {
        this.gstrInputUserName = gstrInputUserName;
        this.gstrInputPassword = gstrInputPassword;
        this.gptyBean = pptyBean;
    }*/

    public CheckUserLogin(String pstrAuthorizationType,String pstrADAliasList,String pstrDBAlias,String pstrValidTable, String pstrUidFld,
                                     String pstrPWFld) throws Exception {
        if(pstrAuthorizationType.toUpperCase().equals("AD")){
            if(pstrADAliasList==null || pstrADAliasList.trim().equals("")){
                throw new Exception("can't find ad server list for use AD authorization!!");
            }
        }
        else if(pstrAuthorizationType.toUpperCase().equals("TABLE")){
            if(pstrDBAlias==null || pstrDBAlias.trim().equals("") || pstrUidFld==null || pstrUidFld.trim().equals("") || pstrPWFld==null || pstrPWFld.trim().equals("")){
                throw new Exception("authoriztion table cant find data user for table authorization!!");
            }
        }

        this.gstrAuthoriztionType=pstrAuthorizationType;
        this.gstrADAliasList=pstrADAliasList;
        this.gstrDBAlias=pstrDBAlias;
        this.gstrUidFld=pstrUidFld;
        this.gstrPWFld=pstrPWFld;
    }

    /**
     * 驗證後傳回資料庫中使用者名稱，用來給前端當session (gstrEmpName)用的
     * @return String
     */
    public String getEmpname() {
        return gstrEmpName;
    }

    /**
     * 傳回資料庫中使用者ID，用來給前端當session (gstrEmpno)用的
     * @return String
     */
    public String getEmpno() {
        return gstrEmpno;
    }

    /**
     * 傳回錯誤訊息
     * @return String
     */
    public String getErrMsg() {
        return gstrErrMsg;
    }

    /**
     * 設定User ID
     * @param gstrInputUserName String
     */
    public void setUsername(String gstrInputUserName) {
        this.gstrInputUserName = gstrInputUserName.trim();
    }

    /**
     * 取得要驗證的User ID
     * @return String
     */
    public String getUsername() {
        return gstrInputUserName;
    }

    /**
     * 設定要驗證的Password
     * @param gstrInputPassword String
     */
    public void setPassword(String gstrInputPassword) {
        this.gstrInputPassword = gstrInputPassword.trim();
    }

    /**
     * 新的認證方式 2006/9/25 建構
     * @param pstrAuthorizationType web.xml 中所記錄的要驗證的方法
     * @return boolean
     */
    public boolean isValidUser(String pstrAuthorizationType){
        boolean lblnAuthorizationResult=false;

        if(pstrAuthorizationType.toUpperCase().equals("AD")){
            lblnAuthorizationResult=checkUserForADList(gstrADAliasList);
        }
        else if(pstrAuthorizationType.toUpperCase().equals("TABLE")){
            //lblnAuthorizationResult=checkUserForTable(gstrDBAlias,gstrValidTable,gstrUidFld,gstrPWFld);
        }

        return lblnAuthorizationResult;
    }

    /**
     * checkUserForADList
     *
     * @param pstrADAliasList String
     * @return boolean
     */
    private boolean checkUserForADList(String pstrADAliasList) {
        return false;
    }

    /**
     * 驗證是否為合法User ，驗證方法則是定義在DB_Config中的AD or Table
     * @return boolean
     * //@deprecated change to use isValidUser(String strAuthoriztionType)
     */
    public boolean isValidUser() {
        try {
            setBundleValue(); //讀取strCheckType變數值
            if (strCheckType.equalsIgnoreCase("AD")) {
                return checkUserForAD();
            } else if (strCheckType.equalsIgnoreCase("TABLE")) {
                return checkUserForTable();
            } else {
                return false;
            }
        } catch (Exception e) {
            System.out.println("\n" +
                               this.toString().substring(this.toString().
                    lastIndexOf('.') + 1, this.toString().lastIndexOf('@')) +
                               ".java" + " (isValidUser) --> Exception=" +
                               e.toString());
            return false;
        } finally {}
    }

    /**
     * 讀取 DB_Config 中第 n 個AD server的連線
     * @param intAD_loop_num int
     * @deprecated
     */
    private void setBundleValue2(int intAD_loop_num) {
        strAD_URL = "ldap://172.19.10.40/cn=pidoperator,DC=dlink,DC=com,DC=tw"; //AD驗證的ldap URL
        strAD_CON = "cn=users,DC=dlink,DC=com,DC=tw"; //AD驗證的container設定
        try {
            PropertyBean objRB = new PropertyBean("DB_Config"); //代表要讀取DB_Config.properties
            strAD_URL = objRB.getString("AD_URL_" +
                                        String.valueOf(intAD_loop_num));
            strAD_CON = objRB.getString("AD_CON_" +
                                        String.valueOf(intAD_loop_num));
        } catch (Exception e) {
            strAD_URL =
                    "ldap://172.19.10.40/cn=pidoperator,DC=dlink,DC=com,DC=tw"; //AD驗證的ldap URL
            strAD_CON = "cn=users,DC=dlink,DC=com,DC=tw"; //AD驗證的container設定
            System.out.println("\n" +
                               this.toString().substring(this.toString().
                    lastIndexOf('.') + 1, this.toString().lastIndexOf('@')) +
                               ".java" +
                               " (setBundleValue2) --> 嚴重的錯誤,請檢查DB_Config.properties中是否有包含如下設定=>AD_URL,AD_CON");
        }
    }

    /**
     * 目的：讀取 DB_Config 中的變數設定值
     * @deprecated 使用新的method後(isValidUser(String pstrAuthorizationType)，此method就用不到了；為向下相容暫時保留
     */
    private void setBundleValue() {
        gblnDebug = true;
        gstrSpecialPassword = ""; //如果沒指定的話，則代表不設定萬用密碼
        strCheckType = "AD"; //如果沒指定的話，則預設為AD
        intAD_NUM = 1; //AD驗證的主機數目，預設一組新竹的
        try {
            //PropertyBean objRB = new PropertyBean("DB_Config"); //代表要讀取DB_Config.properties
            gblnDebug = this.gptyBean.getBoolean("DEBUG"); //測試，從DB_Config.properties 的DEBUG變數做設定
            gstrSpecialPassword = this.gptyBean.getString("SPECIAL_PASSWORD"); //特殊密碼，從DB_Config.properties 的SPECIAL_PASSWORD變數做設定
            strCheckType = this.gptyBean.getString("CHECK_TYPE");
            if (strCheckType.equalsIgnoreCase("ACTIVE_SITE")) {
                strCheckType = this.gptyBean.getString(this.gptyBean.getString(
                        "ACTIVE_SITE") +
                        "_AUTHORITY_CHECK_TYPE");
            }
            intAD_NUM = this.gptyBean.getInt("AD_NUM");
        } catch (Exception e) {
            gblnDebug = true;
            gstrSpecialPassword = ""; //如果沒指定的話，則代表不設定萬用密碼
            strCheckType = "AD"; //如果沒指定的話，則預設為AD
            intAD_NUM = 1; //AD驗證的主機數目，預設一組新竹的
            System.out.println("\n" +
                               this.toString().substring(this.toString().
                    lastIndexOf('.') + 1, this.toString().lastIndexOf('@')) +
                               ".java" + " (setBundleValue) --> 嚴重的錯誤,請檢查DB_Config.properties中是否有包含如下設定=>DEBUG,SPECIAL_PASSWORD,CHECK_TYPE,AD_NUM");
        }
    }

    /* 目的：依照 DB_Config中設定的AD數目 (AD_NUM) 依序做AD驗證
       傳入：無，請先使用 setUsername , setPassword 方法設定 (帳號、密碼)
       傳回：true(驗證正確),false(驗證錯誤) ,一但有一組可以驗證，就回傳true */
    private boolean loopAD() {
        boolean blnValid = false; //true 代表驗證正確，false 代表驗證錯誤

        try {
            if (gblnDebug) {
                System.out.println("\n" +
                                   this.toString().substring(this.toString().
                        lastIndexOf('.') + 1, this.toString().lastIndexOf('@')) +
                                   ".java" + " (loopAD) === Start ===");
            }
            setBundleValue(); //讀取 intAD_NUM 的值
            for (int i = 1; i <= intAD_NUM; i++) {
                blnValid = false;
                if (gblnDebug) {
                    System.out.println("***** 第 " + i + " 台 AD 開始驗證 *****");
                }
                setBundleValue2(i); //讀取strAD_URL,strAD_CON的值
                if (gblnDebug) {
                    System.out.println("***** 設定值 : AD_URL_" + String.valueOf(i) +
                                       " ==> " + strAD_URL);
                }
                if (gblnDebug) {
                    System.out.println("***** 設定值 : AD_CON_" + String.valueOf(i) +
                                       " ==> " + strAD_CON);
                }
                //啟動AD認證
                DirContext ctx = null;
                Hashtable<String,Object> env = new Hashtable<String,Object>();
                env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
                        "com.sun.jndi.ldap.LdapCtxFactory");
                env.put(javax.naming.Context.PROVIDER_URL, strAD_URL);
                env.put(javax.naming.Context.SECURITY_AUTHENTICATION, "Simple");
                env.put(javax.naming.Context.SECURITY_PRINCIPAL,
                        "cn=" + gstrInputUserName + "," + strAD_CON);
                env.put(javax.naming.Context.SECURITY_CREDENTIALS, gstrInputPassword);
                //for 新竹用的AD
                /*
                 env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
                 env.put(javax.naming.Context.PROVIDER_URL, "ldap://172.19.10.40/cn=pidoperator,DC=dlink,DC=com,DC=tw");
                 env.put(javax.naming.Context.SECURITY_AUTHENTICATION,"Simple");
                 env.put(javax.naming.Context.SECURITY_PRINCIPAL,"cn="+gstrInputUserName+",cn=users,DC=dlink,DC=com,DC=tw");
                 env.put(javax.naming.Context.SECURITY_CREDENTIALS , gstrInputPassword ); */
                try {
                    if (gblnDebug) {
                        System.out.println("***** Step 1: Userid=" + gstrInputUserName +
                                           " gstrInputPassword=" + gstrInputPassword);
                    }
                    ctx = new InitialDirContext(env);
                    if (gblnDebug) {
                        System.out.println("***** 第 " + i +
                                           " 台 AD 驗證 OK !! *****");
                    }
                    gstrEmpno = gstrInputUserName;
                    blnValid = true;
                    return blnValid; //直接回傳回去，不再跑迴路了
                } catch (javax.naming.AuthenticationException authe) {
                    if (gblnDebug) {
                        System.out.println("***** Step 2: fail --> " +
                                           authe.toString());
                    }
                    if (gblnDebug) {
                        System.out.println("***** 第 " + i +
                                           " 台 AD 驗證 fail !! *****\n");
                    }
                    blnValid = false;
                } catch (Exception e) {
                    if (gblnDebug) {
                        System.out.println("***** Step 3: fail --> " +
                                           e.toString());
                    }
                    if (gblnDebug) {
                        System.out.println("***** 第 " + i +
                                           " 台 AD 驗證 fail !! *****\n");
                    }
                    blnValid = false;
                } finally {
                    try {
                        ctx.close();
                    } catch (Exception Ignore) {}
                }
            } //End-for
            return blnValid;
        } catch (Exception ex) {
            System.out.println("\n" +
                               this.toString().substring(this.toString().
                    lastIndexOf('.') + 1, this.toString().lastIndexOf('@')) +
                               ".java" + " (loopAD) --> Exception=" +
                               ex.toString());
            blnValid = false;
            return blnValid;
        } finally {
            if (gblnDebug) {
                System.out.println(this.toString().substring(this.toString().
                        lastIndexOf('.') + 1, this.toString().lastIndexOf('@')) +
                                   ".java" + " (loopAD) === End ===");
            }
        }
    }

    /**
     * 驗證 使用者輸入的帳號是否正確 (使用AD驗證)
     * @return boolean
     */
    public boolean checkUserForAD() {
        boolean blnValid = false; //true 代表驗證正確，false 代表驗證錯誤

        gstrEmpno = ""; //初始化empno的值
        gstrErrMsg = "(Invalid UserID or Password)"; //初始化errMsg的值

        if (gstrInputUserName == null) {
            setUsername(""); //若userName=null,則變成空白
        }
        if (gstrInputPassword == null) {
            setPassword(""); //若userName=null,則變成空白
        }

        if (gstrInputUserName.equals("") || gstrInputPassword.equals("")) { //若 gstrInputUserName=空白 or gstrInputPassword=空白，則回傳false
            if (gblnDebug) {
                System.out.println("\n*** 使用 AD 做驗證, 驗證失敗(因為帳號或密碼空白) : UserId=" +
                                   gstrInputUserName + " ,gstrInputPassword=" + gstrInputPassword);
            }
            return blnValid;
        }

        if (gstrInputUserName.indexOf("'") != -1 || gstrInputPassword.indexOf("'") != -1) { //防止資料隱碼攻擊
            if (gblnDebug) {
                System.out.println("\n*** 使用 AD 做驗證, 驗證失敗(因為含有單引號) : UserId=" +
                                   gstrInputUserName + " ,gstrInputPassword=" + gstrInputPassword);
            }
            return blnValid;
        }

        //密碼後門，若不需要就拿掉
        setBundleValue();
        if ((!gstrSpecialPassword.trim().equals("")) &&
            PublicEncryption.getEncryptionString("MD5",
                                                 gstrInputPassword).equals(gstrSpecialPassword.
                trim())) {
            gstrEmpno = gstrInputUserName;
            gstrErrMsg = "";
            blnValid = true;
            return blnValid;
        }
        //---------------------

        try {
            blnValid = loopAD(); //呼叫AD認證的迴路
            if (blnValid == true) {
                gstrErrMsg = ""; //如果認證通過，則清空錯誤訊息
                if (gblnDebug) {
                    System.out.println("\n*** 使用 AD 做驗證, 驗證成功 !! ***");
                }
            } else {
                if (gblnDebug) {
                    System.out.println("\n*** 使用 AD 做驗證, 驗證失敗(因為帳號或密碼錯誤!!) ***");
                }
            }
            return blnValid;
        } catch (Exception ex) {
            System.out.println("\n" +
                               this.toString().substring(this.toString().
                    lastIndexOf('.') + 1, this.toString().lastIndexOf('@')) +
                               ".java" + " (checkUserForAD) --> Exception=" +
                               ex.toString());
            blnValid = false;
            return blnValid;
        }
    }

    /**
     * 驗證Local端 , DB的使用者，Default 使用 wkf_user 這個table做認證
     * @return boolean
     * @deprecated use checkUserForTable(String strValidTable, String strUidFld, String strPWFld)
     */
    public boolean checkUserForTable() {
        boolean blnValid = false; //true驗證正確，false驗證錯誤

        gstrEmpno = ""; //初始化empno的值
        gstrErrMsg = "(Invalid UserID or Password)"; //初始化errMsg的值
        if (gstrInputUserName == null) {
            setUsername(""); //若userName=null,則變成空白
        }
        if (gstrInputPassword == null) {
            setPassword(""); //若userName=null,則變成空白
        }
        if (gstrInputUserName.indexOf("'") != -1 || gstrInputPassword.indexOf("'") != -1) { //防止資料隱碼攻擊
            if (gblnDebug) {
                System.out.println(
                        "\n*** 使用表格 (wkf_user) 做驗證, 驗證失敗(因為含有單引號) : UserId=" +
                        gstrInputUserName + " ,gstrInputPassword=" + gstrInputPassword);
            }
            return blnValid;
        }
        QueryBean qb = null;
        //啟動 WKF_USER 表格驗證
        try {
            qb = new QueryBean(gptyBean.getString("DB_ALIAS"),
                               gptyBean.getBoolean("DEBUG"),
                               gptyBean.getString("SOURCE_CHARSET"),
                               gptyBean.getString("TARGET_CHARSET"));
            //int intSYSDATE = PublicFunction.DateToInt(PublicFunction.getSYSDATE()); //紀錄系統日期
            String strSql = "Select Password FROM WKF_USER Where "
                            + "USER_NO='" + gstrInputUserName + "'";
            ArrayList<ArrayList<Object>> arlData = null;
            arlData = qb.querySQL(strSql);
            if (arlData != null) {
                ArrayList<Object> arlTemp = new ArrayList<Object>();
                arlTemp = (ArrayList<Object>) arlData.get(0); //只會有一筆資料才對
                String strUSER_PASS = arlTemp.get(0) == null ? "" :
                                      arlTemp.get(0).toString().trim(); //USER_PASS
                //密碼後門，若不需要就拿掉
                setBundleValue();
                if (PublicEncryption.getEncryptionString("MD5", gstrInputPassword).
                    equals(gstrSpecialPassword.trim())) {
                    gstrEmpno = gstrInputUserName;
                    gstrErrMsg = "";
                    blnValid = true;
                    return blnValid;
                }
                //---------------------
                //如果密碼正確，代表驗證正確
                if (gstrInputPassword.trim().equals(strUSER_PASS)) {
                    blnValid = true;
                    gstrErrMsg = ""; //驗證正確，沒有錯誤訊息
                } else {
                    gstrErrMsg = "(Invalid Password)";
                }
            }
            if (gblnDebug) {
                System.out.println("\n*** 使用表格 (wkf_user) 做驗證 : " +
                                   (blnValid == true ? " 驗證成功!! " : " 驗證失敗!! ") +
                                   " UserId=" + gstrInputUserName + " ,gstrInputPassword=" +
                                   gstrInputPassword);
            }
            return blnValid;
        } catch (Exception ex) {
            System.out.println("\n" +
                               this.toString().substring(this.toString().
                    lastIndexOf('.') + 1, this.toString().lastIndexOf('@')) +
                               ".java" + " (checkUserForTable) --> Exception=" +
                               ex.toString());
            blnValid = false;
            return blnValid;
        } finally {
            try {
                qb.close();
            } catch (Exception e) {
                System.out.println(
                        "無法關閉QueryBean's Connection in EmployeeList.jsp");
            }
            qb = null;
        }
    }

    /**
     * 驗證Local端 , DB的使用者，使用指定的table
     * @param strValidTable Table Name
     * @param strUidFld User ID Field name
     * @param strPWFld User Password field name
     * @return boolean
     */
    public boolean checkUserForTable(String strValidTable, String strUidFld,
                                     String strPWFld) {
        boolean blnValid = false; //true驗證正確，false驗證錯誤

        gstrEmpno = ""; //初始化empno的值
        gstrErrMsg = "(Invalid UserID or Password)"; //初始化errMsg的值
        if (gstrInputUserName == null) {
            setUsername(""); //若userName=null,則變成空白
        }
        if (gstrInputPassword == null) {
            setPassword(""); //若userName=null,則變成空白
        }
        if (gstrInputUserName.indexOf("'") != -1 || gstrInputPassword.indexOf("'") != -1) { //防止資料隱碼攻擊
            if (gblnDebug) {
                System.out.println("\n*** 使用表格 " + strValidTable +
                                   " 做驗證, 驗證失敗(因為含有單引號) : " + strUidFld + "=" +
                                   gstrInputUserName + " ," + strPWFld + "=" + gstrInputPassword);
            }
            return blnValid;
        }
        //啟動 WKF_USER 表格驗證
        QueryBean qb = null;
        try {
            qb = new QueryBean(gptyBean.getString("DB_ALIAS"),gptyBean.getBoolean("DEBUG"),gptyBean.getString("SOURCE_CHARSET"),gptyBean.getString("TARGET_CHARSET"));
            //int intSYSDATE = PublicFunction.DateToInt(PublicFunction.getSYSDATE()); //紀錄系統日期
            String strSql = "Select " + strPWFld + " FROM " + strValidTable +
                            " Where "
                            + strUidFld + "='" + gstrInputUserName + "'";
            ArrayList<ArrayList<Object>> arlData = null;
            arlData = qb.querySQL(strSql);
            if (arlData != null) {
                ArrayList<Object> arlTemp = new ArrayList<Object>();
                arlTemp = (ArrayList<Object>) arlData.get(0); //只會有一筆資料才對
                String strUSER_PASS = arlTemp.get(0) == null ? "" :
                                      arlTemp.get(0).toString().trim(); //USER_PASS
                //密碼後門，若不需要就拿掉
                setBundleValue();
                if (PublicEncryption.getEncryptionString("MD5", gstrInputPassword).
                    equals(gstrSpecialPassword.trim())) {
                    gstrEmpno = gstrInputUserName;
                    gstrErrMsg = "";
                    blnValid = true;
                    return blnValid;
                }
                //---------------------
                //如果密碼正確，代表驗證正確
                if (gstrInputPassword.trim().equals(strUSER_PASS)) {
                    blnValid = true;
                    gstrErrMsg = ""; //驗證正確，沒有錯誤訊息
                } else {
                    gstrErrMsg = "(Invalid Password)";
                }
            }
            if (gblnDebug) {
                System.out.println("\n*** 使用表格 (" + strValidTable + ") 做驗證 : " +
                                   (blnValid == true ? " 驗證成功!! " : " 驗證失敗!! ") +
                                   " UserId=" + gstrInputUserName + " ,gstrInputPassword=" +
                                   gstrInputPassword);
            }
            return blnValid;
        } catch (Exception ex) {
            System.out.println("\n" +
                               this.toString().substring(this.toString().
                    lastIndexOf('.') + 1, this.toString().lastIndexOf('@')) +
                               ".java" + " (checkUserForTable) --> Exception=" +
                               ex.toString());
            blnValid = false;
            return blnValid;
        } finally {
            try {
                qb.close();
            } catch (Exception e) {
                System.out.println(
                        "無法關閉QueryBean's Connection in EmployeeList.jsp");
            }
            qb = null;
        }
    }

	public String getGstrDBAlias() {
		return gstrDBAlias;
	}

	public void setGstrDBAlias(String gstrDBAlias) {
		this.gstrDBAlias = gstrDBAlias;
	}

	public String getGstrADAliasList() {
		return gstrADAliasList;
	}

	public void setGstrADAliasList(String gstrADAliasList) {
		this.gstrADAliasList = gstrADAliasList;
	}

	public String getGstrValidTable() {
		return gstrValidTable;
	}

	public void setGstrValidTable(String gstrValidTable) {
		this.gstrValidTable = gstrValidTable;
	}

	public String getGstrUidFld() {
		return gstrUidFld;
	}

	public void setGstrUidFld(String gstrUidFld) {
		this.gstrUidFld = gstrUidFld;
	}

	public String getGstrPWFld() {
		return gstrPWFld;
	}

	public void setGstrPWFld(String gstrPWFld) {
		this.gstrPWFld = gstrPWFld;
	}

	public String getGstrEncryption() {
		return gstrEncryption;
	}

	public void setGstrEncryption(String gstrEncryption) {
		this.gstrEncryption = gstrEncryption;
	}

	public String getGstrAuthoriztionType() {
		return gstrAuthoriztionType;
	}

	public void setGstrAuthoriztionType(String gstrAuthoriztionType) {
		this.gstrAuthoriztionType = gstrAuthoriztionType;
	}
}
